#include "vector_float2.h"


using namespace frost;

vector_float2::vector_float2(void)
{
	create_vector(0);
}

vector_float2::vector_float2(int s)
{
	create_vector(s);
}

vector_float2::~vector_float2(void)
{
	delete_vector();
}

void vector_float2::create_vector(int s)
{
	if( s == 0)
		vptr = nullptr;
	else
		vptr = unique_ptr<float[]>(new float[s]);
	size = s;
}

void vector_float2::delete_vector()
{
	vptr = nullptr;
	size = 0;
}

void vector_float2::set(float value, int index)
{
	if((0 <= index) && (index < size))
		vptr[index] = value;
}

void vector_float2::read_from_keyboard()
{
	cout << "Skriv in " << size << " st flyttal med ett mellanslag mellan varje: ";
	for(int i = 0; i < size; i++)
		cin >> vptr[i];
}

void vector_float2::print()
{
	cout.precision(2);
	cout << "[";
	for(int i = 0; i < size; i++)
	{
		cout << std::fixed << vptr[i];
		if( i < size - 1 )
			cout << ",";
	}
	cout << "]" << endl;
}